﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcreport.Web.admininfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int aid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(aid);
				}
			}
		}
			
	private void ShowInfo(int aid)
	{
		lcreport.BLL.admininfo bll=new lcreport.BLL.admininfo();
		lcreport.Model.admininfo model=bll.GetModel(aid);
		this.lblaid.Text=model.aid.ToString();
		this.txtaname.Text=model.aname;
		this.txtapwd.Text=model.apwd;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtaname.Text.Trim().Length==0)
			{
				strErr+="aname不能为空！\\n";	
			}
			if(this.txtapwd.Text.Trim().Length==0)
			{
				strErr+="apwd不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int aid=int.Parse(this.lblaid.Text);
			string aname=this.txtaname.Text;
			string apwd=this.txtapwd.Text;


			lcreport.Model.admininfo model=new lcreport.Model.admininfo();
			model.aid=aid;
			model.aname=aname;
			model.apwd=apwd;

			lcreport.BLL.admininfo bll=new lcreport.BLL.admininfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
